using System.Text;
using System.IO;

namespace TwinHead.Frameworks.Morph.Stream
{
    internal class FileReader : AbstractReader
    {
        public FileReader(string fileName, Encoding encoding)
        {
            using (StreamReader sr = new StreamReader(fileName, encoding))
            {
                buff = sr.ReadToEnd();
                pos = 0;
                //sr.Close();
            }
        }

        public FileReader(string fileName) : this( fileName, Encoding.UTF8)
        {
        }

        public FileReader(StreamReader sr)
        {
            if (sr != null)
            {
                if (!sr.EndOfStream)
                {
                    buff = sr.ReadToEnd();
                    pos = 0;
                }

                sr.Close();
            }
        }		
    }
}
